
package xj.graph2d.shapes.block;

import xj.graph2d.DrawShape;
import xj.graph2d.DrawShapeConstants;
import xj.graph2d.TextShape;

public class MethodDeclShape extends SimpleStatementShape {

  public MethodDeclShape() {
    this(false);
  }

  public MethodDeclShape(boolean createComp) {
    super(createComp);
    setStatementType(METHOD_DECL);
  }

  public MethodDeclShape(float x1, float y1, float x2, float y2) { 
    this(x1, y1, x2, y2, false);
  }

  public MethodDeclShape(float x1, float y1, float x2, float y2, 
			boolean createComp) { 
    super(x1, y1, x2, y2, createComp);
    setStatementType(METHOD_DECL);
  }

  @Override
  public DrawShape makeInstance() {
    return new MethodDeclShape(comp != null);
  }

  @Override
  public void setStatementType(int type) { 
    if (type != METHOD_DECL &&
	type != STATIC_METHOD_DECL) { 
      type = METHOD_DECL;
    }
    if (type != this.statementType) { 
      this.statementType = type; 
      
      TextShape textShape = null;
      DrawShape s = findInRole(DrawShapeConstants.ROLE_NODE_LABEL);
      if (s instanceof TextShape) { 
	textShape = (TextShape) s;
	int i = 0; 
	if (type == METHOD_DECL) { 
	  i = 0; 
	} else if (type == STATIC_METHOD_DECL) { 
	  i = 1; 
	}    
	setDisplayName(displayNames[i]); 
	textShape.setDisplayName(displayNames[i]); 
	textShape.setPrompt(prompts[i]);
	textShape.setPrefix(prefixes[i]);
      }
    }
  }

  String[] displayNames = {
    "Method",
    "Static Method",
  };

  String[] prompts = {
    "Type methodName",
    "Type methodName",
  };

  String[] prefixes = {
    null,
    "\u00ABstatic\u00BB ",
  };



}
